package com.hzqy.service.wchat;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.hzqy.persistence.dao.wchat.WchatTvUserWeixinDao;
import com.hzqy.web.vo.WchatTvPlayHistoryVo;
import com.hzqy.web.vo.WchatTvUserVo;


@Service
public class WchatTvUserWeixinService {

	protected final Logger LOG = LoggerFactory.getLogger(getClass());
	
	@Autowired
	private WchatTvUserWeixinDao wchatScanPayDao;
	/**
	 * 查询微信用户信息
	 * @param openId
	 * @return
	 */
	public WchatTvUserVo selectUserInfo(String openId){
		return wchatScanPayDao.selectUserInfo(openId);
	}
	/**
	 * 新增微信用户信息
	 * @param wechatTvUserVo
	 * @return
	 */
	public int insertUserInfo(WchatTvUserVo wechatTvUserVo){
		return wchatScanPayDao.insertUserInfo(wechatTvUserVo);
	}
	/**
	 * 新增微信用户信息
	 * @param wechatTvUserVo
	 * @return
	 */
	public int updateUnBundling(WchatTvUserVo wechatTvUserVo){
		return wchatScanPayDao.updateUnBundling(wechatTvUserVo);
	}
	/**
	 * 查询业务账号绑定用户集合
	 * @param serverId
	 * @return
	 */
	public List<WchatTvUserVo> selectTVWchatUserList(String serverId){
		return wchatScanPayDao.selectTVWchatUserList(serverId);
	}
	/**
	 * TV解绑业务账号与微信账号
	 * @param serverId
	 * @return
	 */
	public int unTVBundling(WchatTvUserVo wchatTvUserVo){
		return wchatScanPayDao.unTVBundling(wchatTvUserVo);
	}
	
	/**
	 * 获取机顶盒绑定微信完成后的用户观看电影记录，业务层可判断此用户是否观看过此电影或连续剧
	 * @param wtphv
	 * @return
	 */
	public WchatTvPlayHistoryVo selectUserPlayTime(WchatTvPlayHistoryVo wtphv) {
		List<WchatTvPlayHistoryVo> wtphvList = wchatScanPayDao.selectUserPlayTime(wtphv);
		if(wtphvList != null && wtphvList.size() > 0)
			return wtphvList.get(0);
		else
			return null;
	}
	
	public int insertUserPlayTime(WchatTvPlayHistoryVo wtphv) {
		return wchatScanPayDao.insertUserPlayTime(wtphv);
	}
	
	public int updateUserPlayTime(WchatTvPlayHistoryVo wtphv) {
		return wchatScanPayDao.updateUserPlayTime(wtphv);
	}
}
